package com.tong.ft_login;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.tong.ft_login.databinding.ActivityLoginBinding;
import com.tong.lib_base.ft_login.model.UserBean;
import com.tong.lib_base.ft_login.service.impl.LoginImpl;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * author:liuzhitong
 * date:2022/2/18
 * description:
 */
public class LoginActivity extends AppCompatActivity {

    private ActivityLoginBinding mBinding;
    public static void start(Context context,String param){
        Intent intent = new Intent(context,LoginActivity.class);
        intent.putExtra("param",param);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_login);
        mBinding.setActivity(this);
        Intent intent = getIntent();
        String param = intent.getStringExtra("param");
        mBinding.textTitle.setText(param);
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    /*登录测试*/
    public void checkLogin(){
        Toast.makeText(this, "点击了登录按钮，3秒后自动返回", Toast.LENGTH_SHORT).show();
        new CountDownTimer(3000,1000){
            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onFinish() {
                Toast.makeText(LoginActivity.this, "请求成功", Toast.LENGTH_SHORT).show();
                EventBus.getDefault().post("请求成功");
                finish();
            }
        }.start();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onReceiveMsg(String message) {
    }
}
